#coding:utf-8 
import major.models as major_model
from pythonems.control import restful_control
from django.contrib.auth.decorators import login_required
@login_required
def major_all_list(request):
    control = {
        "GET": (major_model.Major.search_rf, [], {}),
        "POST": (major_model.Major.create_rf, [], major_model.Major.relation_dict),
    }
    return restFulControl(request, control)
@login_required
def major_in_id(request, major_id):
    control = {
        "PUT": (major_model.Major.update_rf, [major_id], major_model.Major.relation_dict),
        "DELETE": (major_model.Major.dele_rf, [major_id], {}),
    }
    return restFulControl(request, control, {"major_id": major_id})
@login_required
def char_in_major(request, major_id):
    control = {
        "GET": (major_model.Char.search_rf, [], {}),
        "POST": (major_model.Char.create_rf, [], major_model.Char.relation_dict)
    }
    return restFulControl(request, control, {"major_id": major_id})
@login_required
def char_with_id(request, char_id):
    control = {
        "PUT": (major_model.Char.update_rf, [char_id], major_model.Char.relation_dict),
        "DELETE": (major_model.Char.dele_rf, [char_id], )
    }
    return restFulControl(request, control, {"major_id": major_id,
                                             "char_id": char_id,})
